package com.ucar.common.utils.page.mybatis;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.apache.ibatis.session.RowBounds;
import org.hibernate.validator.constraints.Range;

import io.swagger.annotations.ApiModelProperty;

public class MyRowBounds extends RowBounds {

	@ApiModelProperty(value = "当前页")
	@Max(value = 9999999)
	@Min(value = 0)
	private int pageIndex = 0;

	@ApiModelProperty(value = "每页条数")
	@Range(min = 1, max = 999999)
	private int pageSize = 10;

	@ApiModelProperty(value = "起始行", hidden = true)
	private  int offset;
	
	@ApiModelProperty(value = "查询数量", hidden = true)
	private  int limit;

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	@ApiModelProperty(value = "起始行", hidden = true)
	@Max(value = 9999999)
	@Min(value = 0)
	@Override
	public int getOffset() {
		return (this.getPageIndex() - 1) * this.getPageSize();
	}

	@ApiModelProperty(value = "查询数量", hidden = true)
	@Max(value = 9999999)
	@Min(value = 0)
	@Override
	public int getLimit() {
		return this.getPageSize();
	}

}
